<template>
  <div>
    <el-container id="container">
      <!-- header栏 -->

      <el-header>
        <div class="usericon">
          <i class="iconfont icon-guanliyuan1"></i>
        </div>

        <!-- 用户名及工号 -->

        <div class="user">
          <div class="name">
            <b>姓名：{{name}}</b>
          </div>
          <div class="id">
            <b>工号：{{num}}</b>
          </div>
        </div>

        <!-- 退出按钮 -->

        <div class="quit">
          <el-button type="primary" @click="outlogin()">退出</el-button>
        </div>
      </el-header>
      <!-- 侧边导航 -->

      <el-container>
        <el-aside>
          <el-menu
            :default-active="activeIndex"
            class="el-menu-vertical-demo"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
            router
          >
            <el-menu-item index="/home/staff" v-if="quanxian==99">
              <i class="iconfont icon-renyuan-tianjia"></i>
              <span slot="title">&nbsp;员工管理</span>
            </el-menu-item>
            <el-menu-item index="/home/commodity" v-if="quanxian==99">
              <i class="iconfont icon-shangpinguanli"></i>
              <span slot="title">&nbsp;商品管理</span>
            </el-menu-item>
            <el-menu-item index="/home/sale" v-if="quanxian==99">
              <i class="iconfont icon-xiaoshouguanli"></i>
              <span slot="title">&nbsp;销售管理</span>
            </el-menu-item>
            <el-menu-item index="/home/activity" v-if="quanxian==99">
              <i class="iconfont icon-qingdanguanli"></i>
              <span slot="title">&nbsp;促销活动</span>
            </el-menu-item>
            <el-menu-item index="/home/loading" class="staff" v-if="quanxian==99">
              <i class="iconfont icon-icon-test"></i>
              <span slot="title">&nbsp;上货</span>
            </el-menu-item>
            <el-menu-item index="/home/cash" class="cash">
              <i class="iconfont el-icon-menu"></i>
              <span slot="title">&nbsp;收银</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<style scoped>
#container {
  height: 100%;
}

/* 头部样式 */

#container .el-header {
  text-align: left;
  padding-left: 100px;
  background: #409eff;
  height: 60px;
  line-height: 60px;
}
#container .el-header .usericon {
  float: left;
}
#container .el-header i {
  display: inline-block;
  color: #fff;
  font-size: 2.5rem;
}
#container .el-header .user {
  float: left;
  font-size: small;
}
#container .el-header .user .name {
  margin-top: -10px;
}
#container .el-header .user .name,
#container .el-header .user .id {
  height: 22px;
  color: #fff;
}
#container .el-header .quit {
  float: right;
}
#container .el-header .quit a {
  color: #fff;
  text-decoration: none;
}
#container .el-container {
  height: 100%;
}

/* 侧边导航样式 */

#container .el-aside {
  height: 100%;
  background: #273238;
  text-align: center;
}

#container .el-aside .el-menu li {
  background: #273238 !important;
  width: 300px;
}
.el-menu a {
  text-decoration: none;
  color: #fff;
}

#container .el-aside .el-menu .is-active a {
  color: rgb(255, 208, 75);
}

#container .el-aside .el-menu .staff i {
  margin-left: -30px;
}
#container .el-aside .el-menu .cash i {
  margin-left: -30px;
}
#container .el-aside .el-menu .is-active {
  background-color: rgb(84, 92, 100) !important;
}
/* 主体样式 */

#container .el-main {
  height: 100%;
  background: rgb(255, 255, 255);
}
</style>
<script>
import stroe from '../store/index'
export default {
  name: "home",
  data() {
    return {
      activeIndex:'',
      num:'',
      name:'',
      quanxian:''
    };
  },
  methods: {
    outlogin() {
      sessionStorage.removeItem("user");
      this.$router.push("/login");
    },
  },
  mounted(){
    this.activeIndex=window.location.pathname
    this.num=stroe.state.user.num
    this.name=stroe.state.user.name
    this.quanxian=stroe.state.user.quanxian
  }
};
</script>